$(function(){
	var bgpage = chrome.extension.getBackgroundPage(); 
	var port = chrome.runtime.connect({name: "popup"}); 
	//bgpage.doit();
	var postCmd = function(cmd,callback){
		port.postMessage({command:cmd});
		port.onMessage.addListener(callback);
	};
	$('#used').click(function(e){

		/*chrome.tabs.query({active:true,currentWindow:true},function(tabs){
			chrome.tabs.sendMessage(tabs[0].id,{txt:'on'},function(d){
				//chrome.tabs.executeScript(null,{file:"content.js"});
				console.log(d);
			});

		});*/
		//bgpage.doit();
		//
		postCmd('on',function(msg){
			console.log(msg);
			window.close();
		});
	});
	$('#close').click(function(e){
		postCmd('off',function(msg){
			console.log(msg);
			window.close();
		});
	});
});






